<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/_mozilla/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
promise_test(() => {
    window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate);
    return window.navigator.bluetooth.requestDevice({
        filters: [{services: [heart_rate.name]}],
        optionalServices: [generic_access.name]
    })
    .then(device => device.gatt.connect())
    .then(gattServer => gattServer.getPrimaryService(generic_access.name))
    .then(service => service.getCharacteristic(device_name.name))
    .then(characteristic => characteristic.getDescriptors())
    .then(descriptors => {
        assert_equals(descriptors.length, 4);
        assert_equals(descriptors[0].uuid, number_of_digitals.uuid);
        assert_equals(descriptors[1].uuid, number_of_digitals.uuid);
        assert_equals(descriptors[2].uuid, characteristic_user_description_uuid);
        assert_equals(descriptors[3].uuid, client_characteristic_configuration.uuid);
    });
}, 'Find descriptors with UUID in service.');
</script>
